#import "FontIconCollectionView.h"
#import "FontIconCollectionViewItem.h"
#import "NSImage+QuickLook.h"

@implementation FontIconCollectionView

-(void)setSubviewSize:(CGFloat)theSubviewSize {
	[self setMaxItemSize:NSMakeSize(theSubviewSize,theSubviewSize)];
	[self setMinItemSize:NSMakeSize(theSubviewSize,theSubviewSize)];
}
- (NSCollectionViewItem *)newItemForRepresentedObject:(id)object {
	FontIconCollectionViewItem* item = (FontIconCollectionViewItem*)[super newItemForRepresentedObject:object];
	//FontIconCollectionViewItem* item = [object item];
	//item = nil;
	//NSLog(@"newItemForRepresentedObject:%@ oldItem: %@",[item, [(GSFont*)object image]);

	/*if (item == nil) {
		item = (FontIconCollectionViewItem*)[super newItemForRepresentedObject:object];
		//NSLog(@"item collectionView: %@", [item collectionView]);
		[(GSFont*)object setItem:item];
		[(GSFont*)object setItemView:(FontIconView*)item.view];
		

	} else {
		[item retain];
		[item setRepresentedObject:object];
		[item setView:[object itemView]];
		
	}*/
	UKLog(@"object: %@", object);
	if (![object valueForKey:@"icon"]) {
		UKLog(@"item: %@", [object valueForKey:@"family"]);
		[object setValue: [NSImage imageWithPreviewOfFileAtPath:[object valueForKey:@"filePath"] ofSize:NSMakeSize(95, 90) asIcon:NO] forKey:@"icon"];
	}
	//NSLog(@"newItemForRepresentedObject:%@ layoutView: %@", item, [item layoutView]);
	return item;
}

@end
